package graduate.wangyaqi.FillingQuestions;

import graduate.wangyaqi.SeveralQuestions.SeveralQuestions;
import graduate.wangyaqi.SeveralQuestions.SeveralQuestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.Optional;

@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping(path="/FillingQuestions")
public class FillingQuestionsController {
    @Autowired
    private FillingQuestionsService fillingQuestionsService;

    @GetMapping(path="/getAllByTaotiID")
    public Iterable<FillingQuestions> getAllByTaotiID(int id){
        Iterable<FillingQuestions> list= fillingQuestionsService.getAllByTaotiID(id);
        return list;
    }
    @GetMapping(path="/delete")
    public @ResponseBody
    void Del(Long id) {
        fillingQuestionsService.delete(id);
    }

    @PostMapping(path="/save")
    public boolean save(@RequestBody FillingQuestions fillingQuestions){
        fillingQuestions.setJointime(new Date());
        fillingQuestionsService.save(fillingQuestions);
        return true;
    }

    @GetMapping(path="/findById")
    public Optional<FillingQuestions> findById(Long aLong){
        return fillingQuestionsService.findById(aLong);
    }
}
